var data = null;
function a(){
    return new Promise(function(resolve,reject){
        setTimeout(function(){
            console.log('ok');
            data = 'hello world'
            resolve();
        },1000)
    })
}

function b(){
    console.log(data);
}
a.then(b)
a()
.then(()=>{
    b()
})
.catch(err=>{
    console.log(err,'xxxx');
})